#include <iostream>
#include <map>

using namespace std;

double Power1(double base, int exponent) {
	double mul(1.);
	bool flag = false;
	if (exponent < 0) {
		flag = true;
		exponent = -exponent;
	}
	while (exponent)
	{
		mul *= base;
		--exponent;
	}
	if (flag) mul = 1 / mul;
	return mul;
}

double Power(double base, int exponent) {
	static map<int,double> multiplies;
	multiplies[0] = 1.0;
	multiplies[1] = base;

	int s = multiplies.size();
	if (exponent < s) 
		return multiplies[exponent];
	else
	{
		double x = multiplies[s - 1] * Power(base, exponent - s -1);
		multiplies[exponent] = x;
		return x;
	}
}


//int main()
//{
//	cout << Power(2, 3) << endl;
//	cout << Power(3, 0) << endl;
//	cout << Power(3, -1) << endl;
//
//	system("pause");
//	return 0;
//}